const fs = require('fs');
const path = require('path');
const root = path.resolve(__dirname, '../dist');
console.log('clean dist...');
console.log(root);
const removeDir = (dirName) => {
    const children = fs.readdirSync(dirName, {withFileTypes: true});
    children.forEach(child => {
        const pahtName = path.resolve(dirName,child.name);
        if(child.isDirectory()){
            removeDir(pahtName);
        } else if(child.isFile()){
            fs.unlinkSync(pahtName);
        }
    });
    fs.rmdirSync(dirName);
}
if (fs.existsSync(root)) {
    removeDir(root);
}